package com.pengbei.enshrine.ui.encyclopedia;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.pengbei.enshrine.R;
import com.pengbei.enshrine.base.BaseFragment;
import com.pengbei.enshrine.common.utils.StatusBarUtils;

public class EncyclopediaFragment extends BaseFragment {


    @Override
    public void onResume() {
        super.onResume();
        if (!isValid()){
            return;
        }
        StatusBarUtils.StatusBarWhiteBgBlackText(mActivity);
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_encyclopedia, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initview(view);
        refreshData();
    }

    private void initview(View view){

    }

    public void refreshData() {

    }

    private AppCompatActivity mActivity;

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        mActivity = (AppCompatActivity) context;
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mActivity = null;  // 清理Activity引用
    }

    private boolean isValid(){
        boolean isValid = true;
        if(null==mActivity||mActivity.isFinishing()||mActivity.isDestroyed()){
            isValid = false;
        }
        return isValid;
    }

}
